<html>
 <head>
  <meta charset="UTF-8">
 </head>
 <body>
  <h1 data-lake-id="P74ti" id="P74ti"><span data-lake-id="u7b0684b3" id="u7b0684b3">典型回答</span></h1>
  <p data-lake-id="ufc11754a" id="ufc11754a"><br></p>
  <p data-lake-id="ub173a699" id="ub173a699"><span data-lake-id="u98dccd5c" id="u98dccd5c">TCP（Transmission Control Protocol，传输控制协议）和UDP（User Datagram Protocol，用户数据报协议）是两种主要的网络传输协议，都位于传输层。</span></p>
  <p data-lake-id="u38aa6aba" id="u38aa6aba"><span data-lake-id="uc73e8d19" id="uc73e8d19">​</span><br></p>
  <p data-lake-id="u8c27bd8b" id="u8c27bd8b"><span data-lake-id="u2b30ac37" id="u2b30ac37">​</span><br></p>
  <p data-lake-id="u6032f2f3" id="u6032f2f3"><span data-lake-id="ub65e6a98" id="ub65e6a98">他们主要有以下区别：</span></p>
  <p data-lake-id="u7d2f2d48" id="u7d2f2d48"><span data-lake-id="u725eec90" id="u725eec90">​</span><br></p>
  <ol list="u1321b519">
   <li fid="ua62aa1d7" data-lake-id="uf97a075c" id="uf97a075c" data-lake-index-type="true"><strong><span data-lake-id="u87c3be61" id="u87c3be61">连接类型</span></strong></li>
  </ol>
  <ul list="ubd9a14d9" data-lake-indent="1">
   <li fid="u639cfd24" data-lake-id="u561cb21d" id="u561cb21d" data-lake-index-type="true"><strong><span data-lake-id="ufa4838ed" id="ufa4838ed">TCP 是一种面向连接的协议</span></strong><span data-lake-id="u74d277b6" id="u74d277b6">。在发送数据之前，它需要建立连接，这通过</span><strong><span data-lake-id="uc1bca045" id="uc1bca045">三次握手</span></strong><span data-lake-id="ud8492d0a" id="ud8492d0a">过程完成。结束后通过</span><strong><span data-lake-id="u6e8ba457" id="u6e8ba457">四次挥手</span></strong><span data-lake-id="u42c2857d" id="u42c2857d">断开连接。</span></li>
   <li fid="u639cfd24" data-lake-id="u70545ccd" id="u70545ccd" data-lake-index-type="true"><span data-lake-id="u71fac6b4" id="u71fac6b4">UDP 是无连接的协议。它发送数据而不预先建立连接。</span></li>
  </ul>
  <ol list="u1321b519" start="2">
   <li fid="ua62aa1d7" data-lake-id="ue6a5634f" id="ue6a5634f" data-lake-index-type="true"><strong><span data-lake-id="u31e62c7e" id="u31e62c7e">可靠性</span></strong></li>
  </ol>
  <ul list="u2156994f" data-lake-indent="1">
   <li fid="u52f26a84" data-lake-id="u6ab878d0" id="u6ab878d0" data-lake-index-type="true"><strong><span data-lake-id="u26928cb4" id="u26928cb4">TCP 提供可靠的数据传输</span></strong><span data-lake-id="u55b8130e" id="u55b8130e">，通过确认和重传机制来确保数据的正确送达。</span></li>
   <li fid="u52f26a84" data-lake-id="u13354c28" id="u13354c28" data-lake-index-type="true"><strong><span data-lake-id="u895b7cd3" id="u895b7cd3">UDP 不保证数据的可靠送达。</span></strong><span data-lake-id="uea025c61" id="uea025c61">它发送数据但不确认接收方是否收到，因此可能会丢失数据包。</span></li>
  </ul>
  <ol list="u1321b519" start="3">
   <li fid="ua62aa1d7" data-lake-id="u5893dcef" id="u5893dcef" data-lake-index-type="true"><strong><span data-lake-id="u7ae66523" id="u7ae66523">速度和效率</span></strong></li>
  </ol>
  <ul list="ue469f0e2" data-lake-indent="1">
   <li fid="ub547c884" data-lake-id="u1aebc576" id="u1aebc576" data-lake-index-type="true"><strong><span data-lake-id="ua3fa5d79" id="ua3fa5d79">TCP 由于其握手和确认机制，速度通常比UDP慢，但更可靠。</span></strong></li>
   <li fid="ub547c884" data-lake-id="u77fd83ce" id="u77fd83ce" data-lake-index-type="true"><span data-lake-id="ua92355d9" id="ua92355d9">UDP</span><span data-lake-id="u1b26b187" id="u1b26b187"> 由于缺乏复杂的错误检查和恢复机制，通常比TCP更快，适用于对实时性要求较高的应用。</span></li>
  </ul>
  <ol list="u1321b519" start="4">
   <li fid="ua62aa1d7" data-lake-id="u1455e74e" id="u1455e74e" data-lake-index-type="true"><strong><span data-lake-id="u0bc208e6" id="u0bc208e6">数据流控制和拥塞控制</span></strong></li>
  </ol>
  <ul list="u7300db9c" data-lake-indent="1">
   <li fid="u0b89f063" data-lake-id="u31553b23" id="u31553b23" data-lake-index-type="true"><strong><span data-lake-id="u9cc25b48" id="u9cc25b48">TCP 有流量控制和拥塞控制机制</span></strong><span data-lake-id="u58a4b23c" id="u58a4b23c">，可以调整数据传输速率以避免网络拥堵。</span></li>
   <li fid="u0b89f063" data-lake-id="u1f83f3e9" id="u1f83f3e9" data-lake-index-type="true"><span data-lake-id="u586c7e1d" id="u586c7e1d">UDP 没有内置的流量控制或拥塞控制机制。</span></li>
  </ul>
  <ol list="u1321b519" start="5">
   <li fid="ua62aa1d7" data-lake-id="u0c605f17" id="u0c605f17" data-lake-index-type="true"><strong><span data-lake-id="ueaa4a182" id="ueaa4a182">头部大小</span></strong></li>
  </ol>
  <ul list="u4d5a275e" data-lake-indent="1">
   <li fid="uec0042f3" data-lake-id="u5e116862" id="u5e116862" data-lake-index-type="true"><strong><span data-lake-id="uf717e1a3" id="uf717e1a3">TCP 头部较大</span></strong><span data-lake-id="ua756b959" id="ua756b959">，最小为20字节，因为它包含更多的控制信息。</span></li>
   <li fid="uec0042f3" data-lake-id="uc2f7ff4f" id="uc2f7ff4f" data-lake-index-type="true"><strong><span data-lake-id="ubdbea77c" id="ubdbea77c">UDP 头部较小</span></strong><span data-lake-id="udcee91b4" id="udcee91b4">，仅8字节，使得其开销更小。</span></li>
  </ul>
  <p data-lake-id="u8b8d5d1f" id="u8b8d5d1f"><span data-lake-id="u1c618af4" id="u1c618af4"><br></span></p>
  <p data-lake-id="u2409f7de" id="u2409f7de"><strong><span data-lake-id="u8b22196e" id="u8b22196e">在使用场景上，TCP 通常用于需要高可靠性的应用，如网页浏览、电子邮件、文件传输等。UDP 适用于实时应用，如视频流、在线游戏和语音通话，其中一些数据丢失是可以接受的。</span></strong></p>
  <p data-lake-id="u7749f063" id="u7749f063"><strong><span data-lake-id="u84cbaa74" id="u84cbaa74">​</span></strong><br></p>
  <table data-lake-id="HjToi" id="HjToi" width-mode="contain" class="lake-table" style="width: 869px">
   <colgroup>
    <col width="150">
    <col width="331">
    <col width="388">
   </colgroup>
   <tbody>
    <tr data-lake-id="u4b5632ed" id="u4b5632ed" style="height: 37px">
     <td data-lake-id="uff62f472" id="uff62f472"></td>
     <td data-lake-id="u830ba276" id="u830ba276">
      <p data-lake-id="u8ac72f49" id="u8ac72f49"><strong><span data-lake-id="u30628715" id="u30628715">TCP</span></strong></p></td>
     <td data-lake-id="ud7a2be93" id="ud7a2be93">
      <p data-lake-id="ue975f973" id="ue975f973"><strong><span data-lake-id="u8cb7bba8" id="u8cb7bba8">UDP</span></strong></p></td>
    </tr>
    <tr data-lake-id="u9c32287d" id="u9c32287d">
     <td data-lake-id="u58633a08" id="u58633a08">
      <p data-lake-id="uc6feea22" id="uc6feea22"><strong><span data-lake-id="u5d672659" id="u5d672659">连接类型</span></strong></p></td>
     <td data-lake-id="uf58894b6" id="uf58894b6">
      <p data-lake-id="ubb90e17f" id="ubb90e17f"><span data-lake-id="u70c02608" id="u70c02608">面向连接，需要三次握手和四次挥手</span></p></td>
     <td data-lake-id="ud4d50848" id="ud4d50848">
      <p data-lake-id="ue0de714c" id="ue0de714c"><span data-lake-id="ub49e202b" id="ub49e202b">无连接</span></p></td>
    </tr>
    <tr data-lake-id="u5c65f50c" id="u5c65f50c" style="height: 37px">
     <td data-lake-id="u24f67957" id="u24f67957">
      <p data-lake-id="uaecf3651" id="uaecf3651"><strong><span data-lake-id="u873d9a9b" id="u873d9a9b">可靠性</span></strong></p></td>
     <td data-lake-id="uef246bc5" id="uef246bc5">
      <p data-lake-id="ucd47ed94" id="ucd47ed94"><span data-lake-id="u6379a6c5" id="u6379a6c5">可靠的数据传输</span></p></td>
     <td data-lake-id="ub6940491" id="ub6940491">
      <p data-lake-id="udf379c0b" id="udf379c0b"><span data-lake-id="u64633f96" id="u64633f96">不保证数据可靠性送达</span></p></td>
    </tr>
    <tr data-lake-id="ucf0aa293" id="ucf0aa293" style="height: 39px">
     <td data-lake-id="u2827c8e0" id="u2827c8e0">
      <p data-lake-id="u642cefa5" id="u642cefa5"><strong><span data-lake-id="u1223bbca" id="u1223bbca">头部大小</span></strong></p></td>
     <td data-lake-id="uf7a5e8e6" id="uf7a5e8e6">
      <p data-lake-id="u68648587" id="u68648587"><span data-lake-id="ue1bcfafd" id="ue1bcfafd" class="lake-fontsize-12" style="color: rgb(15, 15, 15)">20-60字节长度</span></p></td>
     <td data-lake-id="u73e10ae9" id="u73e10ae9">
      <p data-lake-id="u695872f1" id="u695872f1"><span data-lake-id="ubdc5f345" id="ubdc5f345">固定8字节</span></p></td>
    </tr>
    <tr data-lake-id="u31421458" id="u31421458" style="height: 37px">
     <td data-lake-id="uc3847cc5" id="uc3847cc5">
      <p data-lake-id="uc0ca389e" id="uc0ca389e"><strong><span data-lake-id="u4879c20f" id="u4879c20f">速度</span></strong></p></td>
     <td data-lake-id="uf9357451" id="uf9357451">
      <p data-lake-id="u4ca6723a" id="u4ca6723a"><span data-lake-id="u1d57290f" id="u1d57290f">比UDP慢</span></p></td>
     <td data-lake-id="ucd17d497" id="ucd17d497">
      <p data-lake-id="u4fcd56d4" id="u4fcd56d4"><span data-lake-id="ua3abcb87" id="ua3abcb87">比TCP快</span></p></td>
    </tr>
    <tr data-lake-id="ub6baf8d2" id="ub6baf8d2" style="height: 37px">
     <td data-lake-id="uae17acb9" id="uae17acb9">
      <p data-lake-id="u15a83547" id="u15a83547"><strong><span data-lake-id="u93c3e64a" id="u93c3e64a">顺序性</span></strong></p></td>
     <td data-lake-id="u9fd33b3f" id="u9fd33b3f">
      <p data-lake-id="ufc6ef2fd" id="ufc6ef2fd"><span data-lake-id="u0404abaa" id="u0404abaa" class="lake-fontsize-12" style="color: rgb(15, 15, 15)">所有数据包按特定顺序传递给接收者</span></p></td>
     <td data-lake-id="uf5825fc8" id="uf5825fc8">
      <p data-lake-id="ued7986d1" id="ued7986d1"><span data-lake-id="u9852cd60" id="u9852cd60" class="lake-fontsize-12" style="color: rgb(15, 15, 15)">数据报以无特定顺序送达</span></p></td>
    </tr>
    <tr data-lake-id="u1fbca062" id="u1fbca062" style="height: 37px">
     <td data-lake-id="u66eac243" id="u66eac243">
      <p data-lake-id="u40757e5a" id="u40757e5a"><strong><span data-lake-id="u250f33fb" id="u250f33fb">错误检测机制</span></strong></p></td>
     <td data-lake-id="u6fc1ee7c" id="u6fc1ee7c">
      <p data-lake-id="u85bf006d" id="u85bf006d"><span data-lake-id="u59674528" id="u59674528">提供了流量控制、拥塞控制</span></p></td>
     <td data-lake-id="ued472683" id="ued472683">
      <p data-lake-id="u3dc0694e" id="u3dc0694e"><span data-lake-id="u95d689f2" id="u95d689f2">只有基本的错误检测机制，如校验和</span></p></td>
    </tr>
    <tr data-lake-id="ua923fd56" id="ua923fd56" style="height: 37px">
     <td data-lake-id="uc2d92837" id="uc2d92837">
      <p data-lake-id="u8c61b624" id="u8c61b624"><strong><span data-lake-id="u51a61603" id="u51a61603">上层协议</span></strong></p></td>
     <td data-lake-id="u500329fe" id="u500329fe">
      <p data-lake-id="u37a226f7" id="u37a226f7"><span data-lake-id="u1925a02a" id="u1925a02a">HTTP, HTTPs, FTP, SMTP, Telnet</span></p></td>
     <td data-lake-id="u31002f48" id="u31002f48">
      <p data-lake-id="uaa9baeb4" id="uaa9baeb4"><span data-lake-id="u3ef432b6" id="u3ef432b6">DNS, DHCP, TFTP, SNMP, RIP, VoIP</span></p></td>
    </tr>
    <tr data-lake-id="u426a8dae" id="u426a8dae" style="height: 37px">
     <td data-lake-id="u73331319" id="u73331319">
      <p data-lake-id="u985ccbb2" id="u985ccbb2"><strong><span data-lake-id="u0537c208" id="u0537c208">应用场景</span></strong></p></td>
     <td data-lake-id="uf07a6b02" id="uf07a6b02">
      <p data-lake-id="u4867c207" id="u4867c207"><span data-lake-id="u75adffcf" id="u75adffcf">web浏览器、文件传输、邮件</span></p></td>
     <td data-lake-id="u8c377198" id="u8c377198">
      <p data-lake-id="u43b7ab35" id="u43b7ab35"><span data-lake-id="u76d9ce26" id="u76d9ce26">网络游戏，视频流，语音通话等</span></p></td>
    </tr>
   </tbody>
  </table>
 </body>
</html>